Next | Prev | Up | Top | Contents | Index

Choosing Which Colormap to Use

When choosing which colormap to use, follow these heuristics:

  1. First decide whether your program will use RGBA or color-index mode. Some operations, such as texturing and blending, are not supported in color index mode; others, such as lighting, work differently in the two modes. Because of that, RGBA rendering is usually the right choice. (See "Choosing between RGBA and Color-Index Mode" in Chapter 5, "Color," of the OpenGL Programming Guide).

    OpenGL 1.0 and 1.1 and GLX 1.0, 1.1, and 1.2 require an RGBA mode program to use a TrueColor or DirectColor visual, and require a color index mode program to use a PseudoColor or StaticColor visual.

    Note: Remember that RGBA is usually the right choice for OpenGL on a Silicon Graphics system.

  2. Choose a visual. If you intend to use RGBA mode, specify RGBA in the attribute list when calling glXChooseVisual().

    If RGBA is not specified in the attribute list, glXChooseVisual() selects a PseudoColor visual to support color index mode (or a StaticColor visual if no PseudoColor visual is available).

    If the framebuffer configuration extension is available, you can use a TrueColor or DirectColor visual in color index mode. See "The Framebuffer Configuration Extension".

  3. Create a colormap that can be used with the selected visual.

  4. If a PseudoColor or DirectColor visual has been selected, initialize the colors in the colormap.

    Note: DirectColor visuals are not supported on Silicon Graphics systems. Colormaps for TrueColor and StaticColor visuals are not writable.

  5. Make sure the colormap is installed. Depending on what approach you use, you may or may not have to install it yourself:
                             Window *colormap_windows, int count)
Many OpenGL applications use a 24-bit TrueColor visual (by specifying GLX_RGBA in the visual attribute list when choosing a visual). Colors usually look right in TrueColor, and some overhead is saved by not having to look up values in a table. On some systems, using 24-bit color can slow down the frame rate since more bits must be updated per pixel, but this isn't usually a problem.

If you want to adjust or rearrange values in a colormap, you may have to use a PseudoColor visual, which has to be used with color-index mode unless the framebuffer configuration extension is available. Lighting and antialiasing are difficult in color-index mode, and texturing and accumulation don't work at all. It may be easier to use double-buffering and redraw to produce a new differently-colored image, or use the overlay plane. In general, avoid using PseudoColor visuals if possible.

Overlays, which always have PseudoColor colormaps on current systems, are an exception to this.


Next | Prev | Up | Top | Contents | Index